/*
 * @Author: your name
 * @Date: 2021-01-04 09:50:30
 * @LastEditTime: 2021-05-06 10:12:57
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \yellow-member-admin\src\router\index.js
 */
import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

const router = new Router({
  routes: [
    {
      path: "/",
      redirect: "/dashboard"
    },
    {
      path: "/",
      component: () =>
        import(/* webpackChunkName: "home" */ "../layout/Home.vue"),
      meta: { title: "自述文件" },
      children: [
        {
          path: "/dashboard",
          component: () =>
            import(/* webpackChunkName: "dashboard" */ "@/page/home"),
          meta: { title: "系统首页" }
        },
        {
          path: "/edit",
          component: () =>
            import(/* webpackChunkName: "dashboard" */ "@/page/edit"),
          meta: { title: "富文本" }
        },
        {
          path: "/img-list",
          component: () =>
            import(/* webpackChunkName: "dashboard" */ "@/page/img-list"),
          meta: { title: "图片列表" }
        },
        {
          path: "/add-img",
          component: () =>
            import(/* webpackChunkName: "dashboard" */ "@/page/add-img"),
          meta: { title: "添加图片" }
        },
        {
          path: "/qr-code-add",
          component: () =>
            import(
              /* webpackChunkName: "dashboard" */ "@/page/project-code/code-add"
            ),
          meta: { title: "添加二维码" }
        },
        {
          path: "/qr-code-list",
          component: () =>
            import(
              /* webpackChunkName: "dashboard" */ "@/page/project-code/code-list"
            ),
          meta: { title: "二维码列表" }
        },
        {
          path: "/qr-code-edit",
          component: () =>
            import(
              /* webpackChunkName: "dashboard" */ "@/page/project-code/code-edit"
            ),
          meta: { title: "二维码编辑" }
        },
        //基本情况
        {
          path: "/jbqk-jtjj",
          component: () => import("@/page/common/common-no-have"),
          meta: {
            title: "清廉建发建设简介",
            nav: ["基本情况", "清廉建发建设简介"],
            type: "img",
            table_name: "ji_ben_qin_kuang",
            sid: "1"
          }
        },
        {
          path: "/jbqk-zzjg",
          component: () => import("@/page/common/common-no-have"),
          meta: {
            title: "组织架构",
            nav: ["基本情况", "组织架构"],
            type: "img",
            table_name: "ji_ben_qin_kuang",
            sid: "2"
          }
        },
        {
          path: "/jbqk-ryzs",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "荣誉展示",
            nav: ["基本情况", "荣誉展示"],
            table_name: "ji_ben_qin_kuang_son",
            cid: "3"
          }
        },
        //财务融资
        {
          path: "/cwrz-zzqk",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "资质情况",
            nav: ["财务融资", "资质情况"],
            table_name: "cai_wu_rong_zi_son",
            cid: "1"
          }
        },
        {
          path: "/cwrz-sgjf",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "会议培训费",
            nav: ["财务融资", "会议培训费"],
            table_name: "cai_wu_rong_zi_son",
            cid: "2"
          }
        },
        {
          path: "/cwrz-zjpw",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "债卷批文",
            nav: ["财务融资", "债卷批文"],
            table_name: "cai_wu_rong_zi_son",
            cid: "3"
          }
        },

        {
          path: "/cwrz-fxfk",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "风险防控",
            nav: ["财务融资", "风险防控"],
            table_name: "cai_wu_rong_zi_son",
            cid: "4"
          }
        },
        //制度建设
        {
          path: "/zdjs-ysgz",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "议事规则",
            nav: ["制度建设", "议事规则"],
            table_name: "zhi_du_jian_she_son",
            cid: "1"
          }
        },
        {
          path: "/zdjs-rsxz",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "人事行政制度",
            nav: ["制度建设", "人事行政制度"],
            table_name: "zhi_du_jian_she_son",
            cid: "2"
          }
        },
        {
          path: "/zdjs-cwgl",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "财务管理制度",
            nav: ["制度建设", "财务管理制度"],
            table_name: "zhi_du_jian_she_son",
            cid: "3"
          }
        },
        {
          path: "/zdjs-gcgl",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "工程管理制度",
            nav: ["制度建设", "工程管理制度"],
            table_name: "zhi_du_jian_she_son",
            cid: "4"
          }
        },
        {
          path: "/zdjs-zcgl",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "资产管理制度",
            nav: ["制度建设", "资产管理制度"],
            table_name: "zhi_du_jian_she_son",
            cid: "6"
          }
        },
        {
          path: "/zdjs-fwsj",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "法务审计制度",
            nav: ["制度建设", "法务审计制度"],
            table_name: "zhi_du_jian_she_son",
            cid: "7"
          }
        },
        {
          path: "/zdjs-gzzd",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "国资制度",
            nav: ["制度建设", "国资制度"],
            table_name: "zhi_du_jian_she_son",
            cid: "8"
          }
        },
        //工程管理
        {
          path: "/gcgl-zdxm",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "重点项目建设计划",
            nav: ["工程管理", "重点项目建设计划"],
            table_name: "gong_cheng_guan_li_son",
            cid: "3"
          }
        },
        {
          path: "/gcgl-xmjs",
          component: () => import("@/page/project-code/code-list"),
          meta: { title: "项目建设", nav: ["工程管理", "项目建设"] }
        },

        {
          path: "/gcgl-fxfk",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "风险防控",
            nav: ["工程管理", "风险防控"],
            table_name: "gong_cheng_guan_li_son",
            cid: "2"
          }
        },

        //资产管理
        {
          path: "/zcgl-cs",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "资产出售",
            nav: ["资产管理", "资产出售"],
            table_name: "zi_chan_guan_li_son",
            cid: "1"
          }
        },
        {
          path: "/zcgl-cz",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "资产出租",
            nav: ["资产管理", "资产出租"],
            table_name: "zi_chan_guan_li_son",
            cid: "2"
          }
        },
        {
          path: "/zcgl-wx",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "资产维修",
            nav: ["资产管理", "资产维修"],
            table_name: "zi_chan_guan_li_son",
            cid: "3"
          }
        },
        {
          path: "/zcgl-tc",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "停车管理",
            nav: ["资产管理", "停车管理"],
            table_name: "zi_chan_guan_li_son",
            cid: "4"
          }
        },
        {
          path: "/zcgl-fxfk",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "风险防控",
            nav: ["资产管理", "风险防控"],
            table_name: "zi_chan_guan_li_son",
            cid: "6"
          }
        },
        //招标投标
        {
          path: "/zbtb-gcl",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "工程类",
            nav: ["招标投标", "工程类"],
            table_name: "zhao_biao_tou_biao_son",
            cid: "1"
          }
        },
        {
          path: "/zbtb-zcl",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "资产类",
            nav: ["招标投标", "资产类"],
            table_name: "zhao_biao_tou_biao_son",
            cid: "2"
          }
        },
        {
          path: "/zbtb-cwl",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "财务类",
            nav: ["招标投标", "财务类"],
            table_name: "zhao_biao_tou_biao_son",
            cid: "3"
          }
        },
        {
          path: "/zbtb-fxfk",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "风险防控",
            nav: ["招标投标", "风险防控"],
            table_name: "zhao_biao_tou_biao_son",
            cid: "4"
          }
        },
        {
          path: "/zbtb-qt",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "其他",
            nav: ["招标投标", "其他"],
            table_name: "zhao_biao_tou_biao_son",
            cid: "5"
          }
        },

        //党风廉政
        {
          path: "/dflz-dwgk",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "党务公开",
            nav: ["党风廉政", "党务公开"],
            table_name: "lian_zheng_dang_feng_son",
            cid: "1"
          }
        },
        {
          path: "/dflz-fxfk",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "风险防控",
            nav: ["党风廉政", "风险防控"],
            table_name: "lian_zheng_dang_feng_son",
            cid: "2"
          }
        },
        {
          path: "/dflz-jsjy",
          component: () => import("@/page/common/common-list"),
          meta: {
            title: "警示教育",
            nav: ["党风廉政", "警示教育"],
            table_name: "lian_zheng_dang_feng_son",
            cid: "3"
          }
        },
        /*  {
             path: '/dflz-jdxx',
             component: () =>
                 import('@/page/common/common-list'),
             meta: { title: '监督信箱', nav: ['党风廉政', "监督信箱"], table_name: 'lian_zheng_dang_feng_son', cid: '4' }
         }, */
        // 实时动态
        {
          path: "/ssdt",
          component: () => import("@/page/real-time/real-time-list"),
          meta: { title: "实时动态", nav: ["实时动态"] }
        },
        {
          path: "/add-ssdt",
          component: () => import("@/page/real-time/add-real-time"),
          meta: {
            title: "实时动态-三级菜单添加",
            nav: ["实时动态-三级菜单添加"]
          }
        },
        {
          path: "/404",
          component: () =>
            import(/* webpackChunkName: "404" */ "@/page/404.vue"),
          meta: { title: "404" }
        },
        {
          path: "/403",
          component: () =>
            import(/* webpackChunkName: "403" */ "@/page/403.vue"),
          meta: { title: "403" }
        }
      ]
    },
    {
      path: "/login",
      component: () => import(/* webpackChunkName: "login" */ "@/page/login"),
      meta: { title: "登录" }
    },
    {
      path: "*",
      redirect: "/404"
    }
  ]
});
// 导航守卫
// 判断用户是否登录，添加前置导航守卫
router.beforeEach((to, from, next) => {
  document.title = `${to.meta.title} `;
  const token = localStorage.getItem("token");
  if (token) {
    next();
  } else {
    if (to.path === "/login") {
      // 如果是登录页
      next();
    } else {
      next({ path: "/login" });
    }
  }
});
export default router;
